home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / dev / cross / avra-0.4_src.lha / avra-0.4 / map.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-28  |  1.1 KB  |  46 lines

  1. #include "avra.h"
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include "args.h"
  5.  
  6. char *Space(char *n);
  7.  
  8. void write_map_file(struct prog_info *pi)
  9.     {
  10.     FILE *fp;
  11.     struct label *label;
  12.     char File[200],*P;
  13.  
  14.     strcpy(File,(char *)pi->args->first_data->data);
  15.     P = strstr(File,".");
  16.     if( P ) *P = 0;
  17.     strcat(File,".map");
  18.     fp = fopen(File,"w");
  19.     if( fp == NULL ) {
  20.         fprintf(stderr,"Error: cannot write map file\n");
  21.         return;
  22.     }
  23.     for(label = pi->first_constant; label; label = label->next)
  24.         fprintf(fp,"%s%sC\t%04x\t%d\n",label->name,Space(label->name),label->value,label->value);
  25.  
  26.     for(label = pi->first_variable; label; label = label->next)
  27.         fprintf(fp,"%s%sV\t%04x\t%d\n",label->name,Space(label->name),label->value,label->value);
  28.  
  29.     for(label = pi->first_label; label; label = label->next)
  30.         fprintf(fp,"%s%sL\t%04x\t%d\n",label->name,Space(label->name),label->value,label->value);
  31.  
  32.     fprintf(fp,"\n");
  33.     fclose(fp);
  34.     return;
  35.     }
  36.  
  37. char *Space(char *n) {
  38.     int i;
  39.  
  40.     i = strlen(n);
  41.     if( i < 1) return "\t\t\t";
  42.     if( i < 8 ) return "\t\t";
  43.     return "\t";
  44. }
  45.  
  46.